#include<stdio.h>
#include<math.h>
#include<string.h>
#define PI 3.14159265358979323846
int main() {
double a,s;
char data[4];
while(scanf("%lf %lf %s",&s,&a,data)!=EOF) {
	if(strcmp(data,"deg")==0) {
		if (a > 180) {
			a = 360 - a;
		}
		printf("%.6lf ",(6440+s)*(a*PI/180));
	}
	else {
		a /= 60;
		if (a > 180) {
			a = 360 - a;
		}
		printf("%.6lf ",(6440+s)*(a*PI/180));
	}
	printf("%.6lf\n",sqrt(2*(6440+s)*(6440+s)*(1-cos(a*PI/180))));
}
} 
